
class _Stack:
	"""
	通过数据格式List,实现Stack
	"""
	def __init__(self):
		self.items = []

	def push(self, item):
		return self.items.append(item)

	def pop(self):
		return self.items.pop()

	def peek(self):
		return self.items[-1]
	
	def size(self):
		return len(self.items)

	def is_Empty(self):
		return True if self.size() == 0 else False



def one_is_compile():
	"""一种括号的情况下"""
	test_data = '(()(())())'
	s = _Stack()
	for i in test_data:
		if i == "(":
			s.push(i)
		elif i == ")" and s.peek() == '(':
			s.pop()
	if s.is_Empty():
		return True
	return False

def two_is_compile():
	"""多种括号的情况下"""
	test_data = "([][])()"
	s = _Stack()
	for i in test_data:
		if i == "(" or i == "[" or i == "{" or i == "<":
			s.push(i)
		elif (i == ')' and s.peek() == '(') or (i == ']' and s.peek() == '[') or (i == '}' and s.peek() == '{') or (i == '>' and s.peek() == '<'):
			s.pop()
	if s.is_Empty():
		return True
	return False


if __name__ == "__main__":
	res = two_is_compile()
	print(res)